# 记录日志

import logging

logger = logging.getLogger('django.request')


class RequestLogMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        # 记录请求信息
        logger.info(f'Request:{request.method} {request.get_full_path()}')
        response = self.get_response(request)

        # 记录响应信息
        logger.info(f"Response:{response.status_code} {request.get_full_path()}")

        return response
